home *** CD-ROM | disk | FTP | other *** search
- /*
- Free File Selector V0.21
- ファイルセレクタ快適操作版
- Copyright(C)1993 Okome
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <dos.h>
- #include <direct.h>
- #include <EGB.H>
- #include <MOS.H>
- #include <kkstr2.h>
- #include <Normlib.h>
- #include <okome.h>
- #include <col.h>
-
- #define FX4 340
- #define FY4 220
- #define FX3 (FX4-1)
- #define FY3 (FY4-1)
- #define FX2 (FX1+FX3)
- #define FY2 (FY1+FY3)
-
- extern char work[];
- static int FX1=120,FY1=80;
-
- int WIN_MEN_bar(char *tt, int x1, int y1, int x2)
- {
- boxbf( x1,y1,x1+x2,y1+15,cl8,cl9 );
- boxf(x1,y1,x1+strlen(tt)*6+45,y1+15,cl8);
- boxbf(x1,y1,x1+15,y1+15,cl8,cl4);
- font12(x1+28,y1+13,tt,cl15);
- return (0);
- }
-
- static void dvsym(int drv)
- {
- char w[2];
- boxbf(FX1+30, FY1+20, FX1+60, FY1+37, cl8,cl15);
- w[0]='A'+drv-1;
- w[1]=0;
- symbol(FX1+41,FY1+36, w, 16, cl8);
- }
-
- static void dvpos(int s, int fx, struct _find_t fls[])
- {
- int i,j;
- boxf( FX1+8,FY1+44,FX2-24,FY2-24, cl8 );
- boxbf( FX2-20,FY1+44,FX2-4,FY2-24, cl8, cl9 );
- if (fx!=0)
- {
- j = FY1+44+(FY2-FY1-68)*(s/3)/((fx+2)/3);
- i = j+(FY2-FY1-68)*8/((fx+2)/3);
- if (i > FY2-24)
- i = FY2-24;
- boxbf( FX2-20,j,FX2-4, i, cl8, cl15 );
- ubox2( FX2-19,j+1,FX2-5, i, cl15, cl8 );
- for (i = 0; i<3*8 && s+i<fx; i++)
- {
- if ( fls[i+s].attrib & _A_SUBDIR )
- {
- EGB_color( work, 0, cl14 );
- } else {
- EGB_color( work, 0, cl15 );
- }
- print( FX1+9+(i % 3)*8*13, FY1+63+i/3*18, fls[i+s].name );
- }
- } else {
- symbol(FX1+20,FY1+80,"File not found.",16,cl2);
- }
- }
-
- static int dvget( struct _find_t fls[])
- {
- int fx = 0;
- struct _find_t fla;
- if (_dos_findfirst("*.*",_A_ARCH | _A_NORMAL | _A_SUBDIR | _A_RDONLY, &fla )==0)
- {
- do
- {
- fls[fx] = fla;
- fx++;
- } while (_dos_findnext(&fla)==0 && fx<512);
- }
- return (fx);
- }
-
- int OKM_fsel(char *fna, char *msg, unsigned int drv)
- {
- int i, fx, s=0, r=1, mb, mx, my, dmx, dmy, p, k, t=1;
- unsigned int edr, drb;
- struct _find_t fls[512];
- /* struct _diskfree_t fre; */
- /* char w[8]; */
- p = EGB_getWritePage( 0, 0 );
- KAN_getMode(&k);
- KAN_setMode(0x20000);
- EGB_writePage( work, 0 );
- MOS_disp(0);
- OKM_gth( FX1,FY1, FX2,FY2, 1 );
- boxbf( FX1,FY1,FX2,FY2, cl0,cl15 );
- WIN_MEN_bar( msg,FX1,FY1,FX3 );
- boxb(FX1+20, FY1+20, FX1+70, FY1+37, cl8);
- boxb( FX2-40, FY2-21, FX2-4, FY2-3, cl8 );
- font12(FX2-33, FY2-5,"実行",cl8);
- if (drv==0)
- {
- _dos_getdrive(&drv);
- } else {
- if (drv>='a' && drv<='z')
- drv -= 'a'-1;
- if (drv>='A' && drv<='Z')
- drv -= 'A'-1;
- }
- _dos_setdrive(drv,&edr);
- _dos_getdrive(&drv);
- dvsym(drv);
- /* _dos_getdiskfree( drv, &fre );
- font12(FX1+100,FY1+36, _itoa( fre.*fre. ,w,10), cl8); */
- fx = dvget(fls);
- dvpos(0, fx, fls);
- boxb( FX1+16, FY2-20, FX1+128, FY2-2, cl8 );
- MOS_disp(1);
- do
- {
- MOS_rdpos(&mb,&mx,&my);
- keyin(FX1+22,FY2-19,fna,12,cl15,cl8,t);
- t = 0;
- if (mb==1)
- {
- if (mx>FX1+8 && mx<FX2-24 && my>FY1+45 && my<FY2-25)
- { /* ファイル */
- do {
- dmx = (mx-FX1-9)/(8*13);
- dmy = (my-FY1-45)/18;
- i = s + dmx + dmy*3;
- MOS_rdpos(&mb,&mx,&my);
- } while (mb!=0);
- if (i<fx && mx>FX1+8 && mx<FX2-24 && my>FY1+45 && my<FY2-25)
- {
- if ((fls[i].attrib & _A_SUBDIR)==0)
- {
- strcpy(fna,fls[i].name);
- t = 1;
- } else {
- MOS_disp(0);
- _chdir(fls[i].name);
- s = 0;
- fx = dvget(fls);
- dvpos(0, fx, fls);
- MOS_disp(1);
- }
- }
- } else
- if (mx>FX2-20 && mx<FX2-4 && my>FY1+44 && my<FY2-24)
- {
- i = (((fx+2)/3)*(my-FY1-44)/(FY2-FY1-68))*3;
- if (i!=s)
- {
- s = i;
- MOS_disp(0);
- dvpos(s, fx, fls);
- MOS_disp(1);
- }
- }
- if (my>FY1+20 && my<FY1+37)
- {
- if (mx>FX1+20 && mx<FX1+30)
- {
- do
- {
- drv--;
- if (drv==0)
- drv = edr;
- _dos_setdrive(drv,&edr);
- _dos_getdrive(&drb);
- } while(drv!=drb);
- MOS_disp(0);
- dvsym(drv);
- fx = 0;
- MOS_disp(1);
- mbout(&i,&dmx,&dmy);
- }
- if (mx>FX1+60 && mx<FX1+70)
- {
- do
- {
- drv++;
- if (drv>edr)
- drv=1;
- _dos_setdrive(drv,&edr);
- _dos_getdrive(&drb);
- } while(drv!=drb);
- MOS_disp(0);
- dvsym(drv);
- fx = 0;
- MOS_disp(1);
- mbout(&i,&dmx,&dmy);
- }
- if (mx>FX1+30 && mx<FX1+60)
- {
- MOS_disp(0);
- dvsym(drv);
- fx = dvget(fls);
- s = 0;
- dvpos(0, fx, fls);
- MOS_disp(1);
- mbout(&i,&dmx,&dmy);
- }
- }
- if (mx>FX2-40 && mx<FX2-4 && my>FY2-21 && my<FY2-3)
- {
- r = 0;
- }
- }
- if (mb==2 || (mb && mx>FX1 && mx<FX1+15 && my>FY1 && my<FY1+15))
- {
- r =-1;
- }
- } while (r==1);
- mbout(&mb,&mx,&my);
- MOS_disp(0);
- OKM_gth( FX1,FY1, FX2,FY2, 0 );
- MOS_disp(1);
- EGB_writePage( work, p );
- KAN_setMode(k);
- return (r);
- }
-